import 'package:app/common/app_theme.dart';
import 'package:app/common/colors.dart';
import 'package:app/common/tool.dart';
import 'package:app/components/base_scaffold_appbar.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';

import 'leave_detail_controller.dart';

class LeaveDetailView extends GetView{

  LeaveDetailController controller = Get.put(LeaveDetailController());


  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return Scaffold(
      backgroundColor: AppColor.bgColor,
      appBar: BaseAppBar(
        preferredSize: Size(Get.width, AppTool.appBarHEIGHT),
        child: Text('请假详情'),
      ),
      body: GetBuilder<LeaveDetailController>(builder: (_){
        return SafeArea(child: Column(
          children: [
            Expanded(child:   ListView(
              padding: EdgeInsets.all(0),
              children: [
                Container(
                  alignment: Alignment.centerLeft,
                  // height: 45,
                  color: Colors.white,
                  padding: EdgeInsets.only(left: 15,right: 15,top: 15,bottom: 15),
                  child: Row(
                    mainAxisAlignment: MainAxisAlignment.spaceBetween,
                    children: [
                      Text('描述',style: appThemeData.textTheme.subtitle1!.copyWith(fontSize: 15),),
                      Container(
                        alignment: Alignment.centerRight,
                        width: 150,
                        // color: Colors.redAccent,
                        child:Text('${controller.model?.data?.name}',
                          style: appThemeData.textTheme.bodyText1!.copyWith(fontSize: 15),maxLines: 5,),
                      )
                    ],
                  ),
                ),
                SizedBox(height: 1,),
                Container(
                    alignment: Alignment.centerLeft,
                    height: 45,
                    color: Colors.white,
                    padding: EdgeInsets.only(left: 15,right: 15),
                    child:Row(
                      mainAxisAlignment: MainAxisAlignment.spaceBetween,
                      children: [
                        Text('请假人',style: appThemeData.textTheme.subtitle1!.copyWith(fontSize: 15),),
                        Text('${controller.model?.data?.userName}',style: appThemeData.textTheme.bodyText1!.copyWith(fontSize: 15),),
                      ],
                    )
                ),

                SizedBox(height: 1,),
                Container(
                    alignment: Alignment.centerLeft,
                    height: 45,
                    color: Colors.white,
                    padding: EdgeInsets.only(left: 15,right: 15),
                    child:Row(
                      mainAxisAlignment: MainAxisAlignment.spaceBetween,
                      children: [
                        Text('请假类型',style: appThemeData.textTheme.subtitle1!.copyWith(fontSize: 15),),
                        Text('${controller.model?.data?.typeName}',style: appThemeData.textTheme.bodyText1!.copyWith(fontSize: 15),),
                      ],
                    )
                ),

                SizedBox(height: 1,),
                Container(
                    alignment: Alignment.centerLeft,
                    height: 45,
                    color: Colors.white,
                    padding: EdgeInsets.only(left: 15,right: 15),
                    child:Row(
                      mainAxisAlignment: MainAxisAlignment.spaceBetween,
                      children: [
                        Text('开始日期',style: appThemeData.textTheme.subtitle1!.copyWith(fontSize: 15),),
                        Text('${controller.model?.data?.dateStart}',style: appThemeData.textTheme.bodyText1!.copyWith(fontSize: 15),),
                      ],
                    )
                ),
                SizedBox(height: 1,),
                Container(
                    alignment: Alignment.centerLeft,
                    height: 45,
                    color: Colors.white,
                    padding: EdgeInsets.only(left: 15,right: 15),
                    child:Row(
                      mainAxisAlignment: MainAxisAlignment.spaceBetween,
                      children: [
                        Text('结束日期',style: appThemeData.textTheme.subtitle1!.copyWith(fontSize: 15),),
                        Text('${controller.model?.data?.dateEnd}',style: appThemeData.textTheme.bodyText1!.copyWith(fontSize: 15),),
                      ],
                    )
                ),

                SizedBox(height: 1,),
                Container(
                    alignment: Alignment.centerLeft,
                    height: 45,
                    color: Colors.white,
                    padding: EdgeInsets.only(left: 15,right: 15),
                    child:Row(
                      mainAxisAlignment: MainAxisAlignment.spaceBetween,
                      children: [
                        Text('持续时间',style: appThemeData.textTheme.subtitle1!.copyWith(fontSize: 15),),
                        Text('${controller.model?.data?.duration}',style: appThemeData.textTheme.bodyText1!.copyWith(fontSize: 15),),
                      ],
                    )
                ),


                SizedBox(height: 1,),
                Container(
                    alignment: Alignment.centerLeft,
                    height: 45,
                    color: Colors.white,
                    padding: EdgeInsets.only(left: 15,right: 15),
                    child:Row(
                      mainAxisAlignment: MainAxisAlignment.spaceBetween,
                      children: [
                        Text('请假状态',style: appThemeData.textTheme.subtitle1!.copyWith(fontSize: 15),),
                        Text('${controller.model?.data?.state=='draft'?'待提交':
                        controller.model?.data?.state=='confirm'?'待批准':
                        controller.model?.data?.state=='validate'?'已批准':
                        '已拒绝'}',style: appThemeData.textTheme.bodyText1!.copyWith(fontSize: 15),),
                      ],
                    )
                ),

                // Container(
                //     alignment: Alignment.centerLeft,
                //     height: 45,
                //     // color: Colors.white,
                //     padding: EdgeInsets.only(left: 15),
                //     child: controller.model?.data?.isFocus==false?Text('是否关注：否'):Text('是否关注：是')),
                // Divider(),



              ],
            ),),
            SizedBox(
              height: 45,
              width: Get.width-150,
              // width: 100,
              child: MaterialButton(onPressed: (){
                controller.requestDataCancelLeave();
              },
                child: Text('撤销',style: TextStyle(color: Colors.white),),color:AppColor.themeColor,),
            )
          ],
        ),
        );
      }),
    );
  }

}